package cn.onesdream.app.common.exception;

import cn.onesdream.app.common.util.ErrorType;

/**
 * 自定义业务异常
 * @author
 *
 */
public class ServiceException extends Exception{

	private static final long serialVersionUID = 1L;

    private ErrorType errorType;

	public ServiceException() {
        super();
    }

    public ServiceException(String msg) {
        super(msg);
        this.errorType =new ErrorType("999002", null, msg);

    }

    /**
     * 自定义异常传枚举
     * @param errorType
     */
    public ServiceException(ErrorType errorType) {
        super(errorType.getMsg());
        this.errorType = errorType;
    }

    /**
     * 自定义异常传枚举及错误信息
     * @param errorType
     * @param data
     */
    public ServiceException(ErrorType errorType, String data) {
        if (data != null) {
            errorType.setMsg(data);
        }
        this.errorType = errorType;
    }

    public ErrorType getErrorType() {
        return errorType;
    }
}
